package cn.csc.module.shoppingCard.enums;

import cn.hutool.core.util.ArrayUtil;
import lombok.Getter;

/**
 * 交易类型（1-充值，2-消费，3-退款，4-冻结，5-解冻）
 * @author liuchuang
 * @version 1.0
 * @date 2024/1/29 10:17
 * @modify
 */
@Getter
public enum TradeTypeEnum {

    /**
     * 充值
     */
    CHARGE(1, "充值"),

    /**
     * 消费
     */
    CONSUME(2,"消费"),

    /**
     * 退款
     */
    REFUND(3,"退款"),

    /**
     * 冻结
     */
    FREEZE(4,"冻结"),

    /**
     * 解冻
     */
    UNFREEZE(5,"解冻");


    private final Integer type;

    private final String name;

    TradeTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    public static TradeTypeEnum getByType(Integer type) {
        return ArrayUtil.firstMatch(o -> o.getType().equals(type), values());
    }


}
